package com.jframe.sys.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringUtil {

	private static ApplicationContext context = null;
	
	public static void init(){
		if (context == null) {
			System.out.println("初始化Spring");
			context = new ClassPathXmlApplicationContext("applicationContext*.xml");
		}
	}
	
	public static void init(ApplicationContext ctx){
		context = ctx;
	}
	
	public static Object getBean(String bean){
		if (context == null) {
			context = new ClassPathXmlApplicationContext("applicationContext*.xml");
		}
		return context.getBean(bean);
	}
}
